//
//  LYFNavigationController.swift
//  weibohhhh
//
//  Created by fersh on 16/1/3.
//  Copyright © 2016年 fersh. All rights reserved.
//

import UIKit

class LYFNavigationController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            
            var backTitle = "返回"
            
            if childViewControllers.count == 1 {
                
                backTitle = viewControllers.first!.title ?? "返回"
            }
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", titel:backTitle, target: self, action: "backProViewController")
            //隐藏底部的tabBar
            viewController.hidesBottomBarWhenPushed = true
            
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    @objc private func  backProViewController(){
        
        popViewControllerAnimated(true)
    }
    
}
